import { PlayerData, Player } from './player'
const map = new Map<string, Player>()
world.onPlayerJoin(async ({ entity }) => {
    map.set(entity.player.userId, new Player(entity))
    if (!entity.player.userId) return;
    map.get(entity.player.userId)!.interact()
})
world.onPlayerLeave(({ entity }) => {
    map.get(entity.player.userId)!.upData()
})
world.onPress(({ entity, button }) => {
    if (button == GameButtonType.ACTION1) {
        map.get(entity.player.userId)!.bag()
    }
})
world.querySelectorAll('*').forEach((e) => {
    e.onInteract(({ entity }) => {
        if (entity.isPlayer) {
            map.get(entity.player.userId)!.interact(e.id)
        }
    })
})
